package com.nbsaas.boot.agent.rest.convert;

import com.nbsaas.boot.entity.agent.Agent;
import com.nbsaas.boot.agent.api.domain.request.AgentRequest;

import org.springframework.beans.BeanUtils;
import com.nbsaas.boot.rest.api.Converter;
import com.nbsaas.boot.utils.BeanDataUtils;
            import com.nbsaas.boot.entity.agent.AgentCatalog;

/**
* 请求对象转换成实体对象
*/

public class AgentEntityConvert  implements Converter<Agent, AgentRequest> {

    @Override
    public Agent convert(AgentRequest source) {
        Agent result = new Agent();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getCatalog()!=null){
                    AgentCatalog catalog =new AgentCatalog();
                    catalog.setId(source.getCatalog());
                    result.setCatalog(catalog);
                    }
        return result;
    }
}

